from math import sqrt


def is_prime(n):
    assert n > 0
    for factor in range(2, int(sqrt(n))+1):
        if n % factor == 0:
            return False
    return True if n != 1 else False
    

def main():
    fileName = ('a.txt', 'b.txt', 'c.txt')
    fs_list = []
    try:
        for filename in fileName:
            fs_list.append(open(filename, 'w', encoding='utf-8'))
        for number in range(1, 1000):
            if is_prime(number):
                if number <100:
                    fs_list[0].write(str(number)+'\n')
                else number < 1000:
                    fs_list[1].write(str(number)+'\n')
                    

is_prime(1)